package com.yugao.fintech.antelope.system.assembly;

import com.yugao.fintech.antelope.common.core.BaseAssembly;
import com.yugao.fintech.antelope.system.model.entity.SysMicroApp;
import com.yugao.fintech.antelope.system.model.rqrs.microapp.MicroAppResp;
import com.yugao.fintech.antelope.system.model.rqrs.microapp.MicroAppSaveReq;
import com.yugao.fintech.antelope.system.model.rqrs.microapp.MicroAppUpdateReq;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;

/**
 * 微应用
 *

 */
@Mapper(componentModel = "spring")
public interface SysMicroAppAssembly extends BaseAssembly {
  @Mappings({
          @Mapping(source = "canUpdate", target = "canUpdate", qualifiedByName = BOOL_TO_STR),
          @Mapping(source = "canDelete", target = "canDelete", qualifiedByName = BOOL_TO_STR),
          @Mapping(source = "isHidden", target = "isHidden", qualifiedByName = BOOL_TO_STR),
          @Mapping(source = "isExternal", target = "isExternal", qualifiedByName = BOOL_TO_STR),
  })
  MicroAppResp toMicroAppResp(SysMicroApp source);

  @Mappings({
          @Mapping(source = "canUpdate", target = "canUpdate", qualifiedByName = STR_TO_BOOL),
          @Mapping(source = "canDelete", target = "canDelete", qualifiedByName = STR_TO_BOOL),
          @Mapping(source = "isHidden", target = "isHidden", qualifiedByName = STR_TO_BOOL),
          @Mapping(source = "isExternal", target = "isExternal", qualifiedByName = STR_TO_BOOL),
  })
  SysMicroApp toMicroApp(MicroAppSaveReq source);

  @Mappings({
          @Mapping(source = "canUpdate", target = "canUpdate", qualifiedByName = STR_TO_BOOL),
          @Mapping(source = "canDelete", target = "canDelete", qualifiedByName = STR_TO_BOOL),
          @Mapping(source = "isHidden", target = "isHidden", qualifiedByName = STR_TO_BOOL),
          @Mapping(source = "isExternal", target = "isExternal", qualifiedByName = STR_TO_BOOL),
  })
  SysMicroApp toMicroApp(MicroAppUpdateReq source);
}
